FROM python:slim
ENV TERM xterm
WORKDIR /app
RUN sed -i 's|http://deb.debian.org|https://mirrors.aliyun.com|g' /etc/apt/sources.list.d/debian.sources
RUN apt-get update && apt-get install -y curl vim iproute2 git cron
# Clone endpoint-folder
RUN git init
RUN git remote add origin https://gitee.com/lovelyelfpop/macless-haystack.git
RUN git fetch --tags
RUN git checkout tags/1.2.0
# Configure python
RUN pip3 install --upgrade pip
# Enable below ones and Disable requirements when network to python official is very poor
# RUN pip3 install requests~=2.31.0
# RUN pip3 install urllib3~=2.1.0
# RUN pip3 install cryptography~=41.0.7
# RUN pip3 install pbkdf2~=1.3
# RUN pip3 install srp~=1.0.20
# RUN pip3 install fastapi~=0.104.1
# RUN pip3 install uvicorn~=0.24.0.post1
# RUN pip3 install certifi
# RUN pip3 install paho-mqtt
# RUN pip3 install pycryptodome
# RUN pip3 install python-multipart
# RUN pip3 install simplekml
# RUN pip3 install pytz
# RUN pip3 install paho-mqtt
# RUN pip3 install schedule
RUN pip3 install --no-cache-dir -r ./requirements.txt
# Set Crond Task
RUN echo "*/15 * * * * root cd /app && /usr/local/bin/python3 /app/request_reports.py >> /var/log/cron.log 2>&1" > /etc/cron.d/request_reports
RUN chmod 0644 /etc/cron.d/request_reports
RUN touch /var/log/cron.log
RUN chmod 666 /var/log/cron.log
# Run crond and python
CMD cron && tail -f /var/log/cron.log && cd /app && python3 /app/request_reports.py